package net.martinimix.beans.bind.support;

import com.bluemartini.dna.DNABasePair;
import com.bluemartini.dna.DNADouble;

/**
 * Provides a double base pair property editor.
 * 
 * @author Scott Rossillo
 *
 */
public class DoubleBasePairPropertyEditor implements DNABasePairPropertyEditor {

	/**
	 * Creates a new double base pair property editor. 
	 */
	public DoubleBasePairPropertyEditor() {
		super();
	}
	
	/* (non-Javadoc)
	 * @see net.martinimix.dao.bind.support.DNABasePairPropertyEditor#getAsBasePair(java.lang.Object)
	 */
	public DNABasePair getAsBasePair(Object value) {
		
		return new DNADouble( (Double) value );
	}
	
	/* (non-Javadoc)
	 * @see net.martinimix.dao.bind.support.DNABasePairPropertyEditor#setAsBasePair(com.bluemartini.dna.DNABasePair)
	 */
	public Object setAsBasePair(DNABasePair value) {
			
		if(DNABasePair.TYPE_DOUBLE != value.getType()) {
			throw new IllegalArgumentException("Given value must be of type double [" + value + "]");
		}
		
		return (Double) value.getValue();
	}

}
